package com.aichen.starter.code.config;

import com.aichen.starter.code.service.AichenEmailCodeSend;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author aichen
 * @date 2022/7/5 14:55
 */
@Configuration
@ConditionalOnClass({AichenEmailCodeSend.class})
public class AutoCodeConfigure {

    @Value("${aichen.code.name}")
    private String appName;

    @Bean
    @ConditionalOnMissingBean
    public AichenEmailCodeSend aichenEmailCodeSend(){
        return new AichenEmailCodeSend(appName);
    }
}
